package com.sky.controller.test1;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

public class Test02 {
    public static void main(String[] args) {
        Card goldCard = new goldCard("张三","1",2000,123453);


        Card silverCard = new silverCard("李四", "2", 1000, 123456);


    }
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class Card {
    private String cardName;
    private String cardType;
    private double cardMoney;
    private double cardPhone;
    //存储金额方法
    public void addMoney(double money){
        this.cardMoney += money;
    }
    //消费金额方法
    public void payMoney(double money){
        this.cardMoney -= money;
    }

}
class goldCard extends Card{
    public goldCard(String cardName, String cardType, double cardMoney, double cardPhone) {
        super(cardName, cardType, cardMoney, cardPhone);
    }
    //重写消费金额方法,打八折
    @Override
    public void payMoney(double money) {
        setCardMoney(getCardMoney() -money*0.8);
        //消费大于200打印洗车票,不满足打印您不满200
        if (money*0.8>=200){
            printTicket();
        }else {
            System.out.println("您不满足消费200");
        }
    }
    //打印洗车票
    public void printTicket(){
        System.out.println("打八折");
    }
}
class  silverCard extends Card{
    public silverCard(String cardName, String cardType, double cardMoney, double cardPhone) {
        super(cardName, cardType, cardMoney, cardPhone);
    }
    //重写消费金额方法,打八折
    @Override
    public void payMoney(double money) {
        setCardMoney(getCardMoney() -money*0.95);

    }

}
